from contextlib import nullcontext
# a=int(input())
# print(type(a))#<class 'int'>

# a=input()
# b=input()
# c=input()
# print(type(a))#<class 'str'>
# print(type(b))#<class 'str'>
# print(type(c))#<class 'str'>


# a=123
# b=2.5
# print(type(a))
# print(type(b))


# print(1,end=" ")
# print(2,end=" ")
# print(3,end=" ")
# #1 2 3

# for i in range (0,5,1):
#     print(i,end=" ")
# #0 1 2 3 4

#
# for i in range (0,10):
#     if i==5:
#         continue
#     else :print(i,end=" ")
# #0 1 2 3 4 6 7 8 9

#0 1 2 3 4 5 6 7 8 9


# def add(a,b):
#     return a,b
#
# _,x=add(1,5)
# print(_,x)#1 5

from socket import *

server_ip='127.0.0.1'
server_port=8889

#连接服务端
dataSocket=socket(AF_INET,SOCK_STREAM)
#连接服务端
dataSocket.connect((server_ip,server_port))

maxbuffer=1024

while True:
    buffer=input("请输入要发送给服务端的数据\n")
    dataSocket.send(buffer.encode())
    print(f"已经向服务端发送了数据:{buffer}")
    #接受服务端的数据
    rev_buffer=dataSocket.recv(maxbuffer)
    if rev_buffer==nullcontext:
        print("服务端没有收到你发的数据")
    else:
        print(f"服务端收到了你发的数据,并回应:{rev_buffer.decode()}")


